package om.hei.tanhua.mq;
//收件人
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

import org.springframework.stereotype.Component;

@Component
public class MqListener {
    @RabbitListener(
            bindings = @QueueBinding(
                    //接收一个参数，队列的名称
                    value=@Queue("queue.direct"),
                    //注解接收一个参数，参数代表交换器的名称
                    exchange = @Exchange("exchange.direct"),
                    //key 想第一给消息打了一个标签，

                    key = {"itcast"}
            )
    )
    public void listener(String message){
        System.out.println("我接收到的消息是："+message);
    }
}
